
using DaprPlus.Authorization.Application.Queries;
using DaprPlus.Authorization.Domain.Entities;
using DaprPlus.AutoMapper;


namespace Todos.Infrastructure.AutoMapper;

public class RoleResourceMapper : AutoMapperTupleBase
{
    /// <summary>
    /// 执行对象映射构造
    /// </summary>
    public override void CreateMap()
    {
        CreateMap<RoleResource, RoleResourceOutDto>()
            .ForMember(dest => dest.ResourceName,
                cfg => cfg.MapFrom(src => src.Resource == null ? null : src.Resource.Name))
            .ForMember(dest => dest.ResourceCode,
                cfg => cfg.MapFrom(src => src.Resource == null ? null : src.Resource.Code))
            .ForMember(dest => dest.MetadataJson,
                cfg => cfg.MapFrom(src => src.Resource == null ? null : src.Resource.MetadataJson))
            .ForMember(dest => dest.AllowedOperationsJson,
                cfg => cfg.MapFrom(src => src.Resource == null ? null : src.Resource.AllowedOperationsJson));

    }
}
